import { Service } from 'egg';

/**
 * Test Service
 */
export default class feedback extends Service {
  public async submitFeedback(req) {
    const { user_id, mobile, content, images } = req;
    let arr: any = [];
    let array = images.split('@');
    for (let i = 0; i < array.length; i++) {
      arr[i] = await this.ctx.helper.writeImage(array[i])
    }
    let res = await this.ctx.model.Feedback.create({
      content,
      user_id,
      mobile,
      imgs: arr.toString()
    })
    if (res) {
      return res
    } else {
      throw new Error()
    }
  }
}